package tiantao.taogu.TgEnum;

/**
 * 性别
 * 
 * @author jinjianming
 *
 */
public enum GenderEnum {
  UNKNOWN("未知", 0),
  MALE("男", 1),
  FEMALE("女", 2),
  FEMALET_MALE("女性改（变）男性", 5),
  MALE_FEMALE("男性改（变）女性", 6),
  UNSTATED("未说明的性别", 9);

  private String name;
  private int id;

  private GenderEnum(String name, int id) {
    this.name = name;
    this.id = id;
  }

  public static GenderEnum judgeGender(String name) {
    if (MALE.getName().equals(name)) {
      return MALE;
    }
    if (FEMALE.getName().equals(name)) {
      return FEMALE;
    }
    return UNKNOWN;
  }

  public static GenderEnum fromName(String name) {
    for (GenderEnum o : GenderEnum.values()) {
      if (o.name().equals(name)) {
        return o;
      }
    }
    return null;
  }

  public static GenderEnum fromName_(String name) {
    for (GenderEnum o : GenderEnum.values()) {
      if (o.getName().equals(name)) {
        return o;
      }
    }
    return null;
  }

  public static GenderEnum fromId(Integer id) {
    for (GenderEnum o : GenderEnum.values()) {
      if (o.getId() == id) {
        return o;
      }
    }
    return null;
  }

  public static String getName(int id) {
    for (GenderEnum o : GenderEnum.values()) {
      if (o.getId() == id) {
        return o.name;
      }
    }
    return null;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

}